package id.laskarmedia.opnvpn_flutter.handler.OC;


import androidx.annotation.NonNull;

import id.laskarmedia.opnvpn_flutter.util.PermissionUtil;
import id.laskarmedia.opnvpn_flutter.enums.VPNEventEnum;
import id.laskarmedia.opnvpn_flutter.handler.AbstractEventHandler;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;

/**
 * PermissionEventHandler class is a concrete implementation of AbstractEventHandler
 * specifically for handling VPN permission events.
 */
public class PermissionEventHandler extends AbstractEventHandler {

    /**
     * Returns the VPN event type handled by this event handler.
     *
     * @return Null, as this event handler does not handle any specific VPN event.
     */
    @Override
    public VPNEventEnum getVPNEvent() {
        return VPNEventEnum.PERMISSION;
    }

    /**
     * Handles the method call for VPN permission event.
     *
     * @param call   The method call received from Flutter.
     * @param result The result object to send the method call result back to Flutter.
     */
    @Override
    public void handler(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
        result.success(PermissionUtil.requestVPNPermission());
    }
}
